<?php
	$html->addJUI();
	$javascript->link('/cms/js/jquery.ajaxify.js',false);
	//$javascript->link('/cms/js/jquery.template.js',false);
	$javascript->link('/cms/js/jquery.qtip.js',false);
	$editFieldGroup = "edit";
	if(@$deal["Deal"]["status"] == Deal::PUBLISH)
	{
		$editFieldGroup = "edit_published";
	}
?>
<div class="edit_offer_promotion form">
<?php echo $form->create('Deal',array('url'=>'/'.$this->params['url']['url'],'id'=>'deal_form','enctype'=>'multipart/form-data'));?>
<?php $form->defaultEmpty = __("-Select-"); ?>
 	<?php 
 	$assetsAddHtml = $form->input("asset_inputs"); 
	ob_start();
	?>
	<fieldset>
 		<legend><?php __($pageTitle);?></legend>
		<?php
		echo $form->input('id',array('type'=>'hidden'));
		echo $form->inputs(array('fieldset'=>false),null,$editFieldGroup);
		?>
	</fieldset>
	<?php 
	$infoFields = ob_get_clean();
	$tabsHtml = array();
	$tabsHtml[] = array(__("Main Information"),$infoFields,array("container_id"=>"main_info"));
	$infoFields = "";
	?>
	
	<?php
	$imagesContent = "";
	//Images
	if($showImageTab){
	ob_start();	
	?>
	<div>
		<?php echo $this->element('deal_assets_on_edit_page');?>	
		<div>
			<?php echo $assetsAddHtml?>
		</div>
	</div>
	<?php 
	$imagesContent = ob_get_clean();
	$tabsHtml[] = array(__("Images"),$imagesContent,array("container_id"=>"images_content"));
	$imagesContent = "";
	?>
	<?php } ?>
	
	<?php 
	if(count($tabsHtml) > 1)
	{
		foreach($tabsHtml as $tab)
		{
			call_user_func_array(array($tabs,'addtab'), $tab);
		}
		echo $tabs->show();	
	}
	?>
	
<?php echo $form->end(__('Submit'));?>
</div>
<script>
var yearRange = "<?php echo date("Y").":".(date("Y") + 30); ?>";
$(document).ready(function(){
	$( "#DealExpires" ).datepicker( "option", "yearRange", yearRange );
	$( "#DealExpires" ).datepicker( "option", "minDate", 0 );

	$( "#DealPublishOnDate" ).datepicker( "option", "yearRange", yearRange );
	$( "#DealPublishOnDate" ).datepicker( "option", "minDate", 0 );
});
</script>